package com.wangce.dao;

import com.wangce.entity.Dim;
import com.wangce.entity.Goods;
import com.wangce.entity.Order;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * ClassName: OrderDao
 * Description:
 * date: 2021/11/11 20:04
 *
 * @author 凡人
 * @since JDK 1.8
 */
public interface OrderDao {

    /**
     * 列表
     * @return
     */
    List<Order> list(Dim d);

    /**
     * 获取对象
     * @param id
     * @return
     */
    Order getOrder(@Param("id") Long id);

    /**
     *
     * @param order
     * @return
     */
    Integer add(Order order);

    /**
     * 根据名字查询对象
     * @param goodsName
     * @return
     */
    @Select("select * from tb_goods where goods_name = #{goodsName}")
    Goods selectByName(@Param("goodsName") String goodsName);

    /**
     * 添加订单商品表
     * @param orderId
     * @param id
     * @param goodsId
     * @return
     */
    Integer addOG(@Param("orderId") Long orderId, @Param("goodsId") Integer goodsId, @Param("goodsNum") Integer goodsNum);

    /**
     * 添加商品
     * @param goods
     * @return
     */
    Integer addGoods(Goods goods);

    /**
     * 删除主表
     * @param id
     * @return
     */
    @Delete("delete from tb_order where order_id = #{id}")
    Integer delete(@Param("id") Long id);

    /**
     * 删除中间表
     * @param id
     * @return
     */
    @Select("delete from order_goods where order_id=#{id}")
    Integer deleteOG(@Param("id") Long id);
}
